package com.googlecode.smartbinding.framework.core;

import com.googlecode.smartbinding.framework.events.listener.SourceChangedListener;
import com.googlecode.smartbinding.framework.events.listener.TargetChangedListener;
import com.googlecode.smartbinding.framework.events.listener.ValidationStatusChangedListener;

import java.util.List;

/**
 * DataBinding result.
 *
 * @author Iulian Dumitru
 */
public interface BindingResult {

    /**
     * Listen to source changes.
     *
     * @param sourceChangedListener source changed listener
     * @return binding result
     */
    BindingResult addSourceChangedListener(SourceChangedListener sourceChangedListener);

    /**
     * Listen to target changes.
     *
     * @param targetChangedListener target changed listener
     * @return binding result
     */
    BindingResult addTargetChangedListener(TargetChangedListener targetChangedListener);

    /**
     * Retrieve the bindings list.
     *
     * @return - the bindings list.
     */
    List<BindingUnit> getBindings();

    /**
     * Get the databinding context.
     *
     * @return - the databinding context
     */
    BindingContext getBindingContext();

    /**
     * Check if the binding result has validation errors
     *
     * @return - true if validation errors exists false otherwise
     */
    boolean hasValidationErrors();

    /**
     * Update the source with changes from target
     */
    void updateSource();

    /**
     * Update the target with changes from source
     */
    void updateTarget();

}